package com.duyj.server.stock.dao;

import com.duyj.client.stock.model.Stock;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface StockDAO {

    @Update("update tp_stock set count = count - #{num} where code = #{code}")
    void updateStock(String code, int num);

    @Insert("insert into tp_stock(code, name, count) values(#{code}, #{name}, #{count})")
    void insertStock(Stock stock);

    @Select("select count from tp_stock where code = #{code}")
    int getStockCount(String code);

    @Select("select name from tp_stock where code = #{code}")
    String getStockName(String code);
}
